package com.orhanobut.logger;

import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import static com.orhanobut.logger.Utils.checkNotNull;

/**
 * LogCat implementation for {@link LogStrategy}
 *
 * This simply prints out all logs to Logcat by using standard class.
 */
public class LogcatLogStrategy implements LogStrategy {

  static final String DEFAULT_TAG = "NO_TAG";

  @Override public void log(int priority, String tag, String message) {
    checkNotNull(message);

    if (tag == null) {
      tag = DEFAULT_TAG;
    }

    HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00201, tag);
    switch (priority) {
      case HiLog.DEBUG:
         HiLog.debug(label,"%{public}s", message);
         break;
      case HiLog.ERROR:
        HiLog.error(label,"%{public}s", message);
        break;
      case HiLog.FATAL:
        HiLog.fatal(label,"%{public}s", message);
        break;
      case HiLog.WARN:
        HiLog.warn(label,"%{public}s", message);
        break;
      default:
        HiLog.info(label,"%{public}s", message);
        //HiLog.info(label, message, null);
        break;
    }


  }
}
